package com.abel.serviceuser.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
public class Test {
    @Value("${server.port}")
    private String port;
    @GetMapping("/hello")
    public String hello(HttpServletRequest request){
        /*try {
            Thread.sleep(1500);
        }catch (Exception e){
            e.printStackTrace();
        }*/
        HttpSession session=request.getSession();
        System.out.println(session.getId());
     Object object= session.getAttribute("user");
     System.out.println(port);
     if (object==null){
         System.out.println("未登录");
         return  "请登录";
     }
        System.out.println("用户服务");
        return "hello world 端口:"+port;
    }
}
